package com.heyun.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.heyun.bean.HeyunService;
import com.heyun.bean.HeyunServiceFAQ;
import com.heyun.dao.HeyunServiceDao;
import com.heyun.dao.HeyunServiceFAQDao;
import com.heyun.service.HeyunServiceFAQService;
@Service
public class HeyunServiceFAQImpl implements HeyunServiceFAQService{

		@Autowired
		private HeyunServiceFAQDao heyunServiceFAQDao;
		public Map listHeyunServiceFAQ(HeyunServiceFAQ heyunServiceFAQ,int currentPage){
			PageHelper.startPage(currentPage,2);
			/*SqlSession session=sqlSessionFactory.openSession();
			HeyunServiceFAQDao heyunServiceFAQDao=session.getMapper(HeyunServiceFAQDao.class);*/
			List<HeyunServiceFAQ> heyunServiceFAQList=heyunServiceFAQDao.listHeyunServiceFAQ(heyunServiceFAQ);
			PageInfo<HeyunServiceFAQ> p=new PageInfo<HeyunServiceFAQ>(heyunServiceFAQList);
			Map map=new HashMap();
			map.put("heyunServiceFAQList",heyunServiceFAQList);
			for(HeyunServiceFAQ hl:heyunServiceFAQList){
				System.out.println(hl.toString());
			}
			map.put("totalPage",p.getPages());
			
			return map;
		}
		public int insertHeyunServiceFAQ(HeyunServiceFAQ heyunServiceFAQ){
			/*SqlSession session=sqlSessionFactory.openSession();
			HeyunServiceFAQDao heyunServiceFAQDao=session.getMapper(HeyunServiceFAQDao.class);*/
			int a=heyunServiceFAQDao.insertHeyunServiceFAQ(heyunServiceFAQ);
			
			return a;
		}
		public int updateHeyunServiceFAQ(HeyunServiceFAQ heyunServiceFAQ){
			/*SqlSession session=sqlSessionFactory.openSession();
			HeyunServiceFAQDao heyunServiceFAQDao=session.getMapper(HeyunServiceFAQDao.class);*/
			int a=heyunServiceFAQDao.updateHeyunServiceFAQ(heyunServiceFAQ);
			
			return a;
		}
		public int deleteHeyunServiceFAQ(HeyunServiceFAQ heyunServiceFAQ){
			/*SqlSession session=sqlSessionFactory.openSession();
			HeyunServiceFAQDao heyunServiceFAQDao=session.getMapper(HeyunServiceFAQDao.class);*/
			int a=heyunServiceFAQDao.deleteHeyunServiceFAQ(heyunServiceFAQ);
			
			return a;
		}
		public HeyunServiceFAQ getHeyunServiceFAQExtra(HeyunServiceFAQ heyunServiceFAQ){
			/*SqlSession session=sqlSessionFactory.openSession();
			HeyunServiceFAQDao heyunServiceFAQDao=session.getMapper(HeyunServiceFAQDao.class);*/
			HeyunServiceFAQ heyunServiceFAQResult=heyunServiceFAQDao.getHeyunServiceFAQExtra(heyunServiceFAQ);
			System.out.println(heyunServiceFAQResult.toString());
			
			return heyunServiceFAQResult;
		}
}

